const express = require("express")

const app = express()

//在全局添加一个密钥
app.set('secret', '23879ryfhdsnu')

// 引入中间件
// 解决跨域问题
app.use(require('cors')())
app.use(express.json())

// 静态文件托管
app.use('/uploads', express.static(__dirname + '/uploads'))


// 引入数据库
require('./plugins/db')(app)
require('./routes/admin')(app)
require('./routes/web')(app)



var bodyParser = require('body-parser');
app.use(bodyParser.json({limit: '50mb'}));
app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));

app.listen(3000, () => {
    console.log('http://localhost:3000');
})